/*	Copyright 2007 - Xavier Baro (xbaro@cvc.uab.cat)

	This file is part of eapmlib.

    Eapmlib is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or any 
	later version.

    Eapmlib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __XMLOPENCV_H__
#define __XMLOPENCV_H__

#include "EvolutiveLib.h"
#include "Cascade.h"
#include "DissociatedDipole.h"
#include "ThrClassifier.h"
#include "AdditiveClassEnsemble.h"

namespace Evolutive {

	class EVOLUTIVELIB_API CXMLOpenCV
	{
		//! Methods
	public:
		//! Default constructor		
		CXMLOpenCV(void);

		//! Default destructor
		virtual ~CXMLOpenCV(void);	

#ifdef USE_OPENCV
		//! Export a Classifier to an XML file readable by the OpenCV
		void ExportClassifier(CCascade* Classifier,string FileName,string Name);
								
	protected:

		//! Exports a cascaded classifier
		void ExportCascade(fstream &ofs,CCascade *Cascade);

		//! Exports an ensemble of classifiers
		void ExportEnsemble(fstream &ofs,CAdditiveClassEnsemble *Stage);

		//! Exports a simple classifier with a threshold
		void ExportThrClassifier(fstream &ofs,CThrClassifier *Classifier);

		//! Exports a dissociated dipole
		void ExportDipole(fstream &ofs,CDissociatedDipole *Dipole);
					
#endif //USE_OPENCV
		//! Attributes
	protected:	

		//! Puts a double to the output stream
		void PrintDouble(fstream &ofs,double Value);
				
	};	
}

#endif // __XMLOPENCV_H__
